package com.ssm.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ssm.pojo.Info;
import com.ssm.pojo.Position;
import com.ssm.service.InfoService;
import com.ssm.service.PositionService;
import com.ssm.util.DateUtil;

@Controller
@RequestMapping("/find")
public class FindController {
	@Resource
	private InfoService infoService;
	@Resource
	private PositionService positionServiceImpl;
	private DateUtil date;
	
	
	@RequestMapping("/findposition")
	public String findposition(Info info,HttpServletRequest request){
	//	System.out.println(info);
		info.setPubtime(date.getcurrDate());
		int index = infoService.inserinfo(info);
		if(index>0){
			request.getSession().setAttribute("findflag", "发布成功！");
		}else{
			request.getSession().setAttribute("findflag", "服务器繁忙，请稍候再试！");
		}
		
		
		
		return "redirect:/person/findposition.jsp";
	}

	@RequestMapping("/pubposition")
	public String pubposition(Position position,HttpServletRequest request){
	//	System.out.println(position);
		position.setPubtime(date.getcurrDate());
		
		int index = positionServiceImpl.insterPosition(position);
		if(index>0){
			request.getSession().setAttribute("pubflag", "发布成功！");
		}else{
			request.getSession().setAttribute("pubflag", "服务器繁忙，请稍候再试！");
		}
		
		
		
		return "redirect:/company/pubposition.jsp";
	}
}


